package com.heimachefu.common;

import com.heimachefu.module.user.entity.UserEntity;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author liuxingdong@heimachefu.com
 * @date 2019/7/19 17:38
 */
public class BaseController {

    public UserEntity getRequestUser(){
        UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
      return  (UserEntity) authenticationToken.getPrincipal();
    }

}
